<template>
  <a-modal :maskClosable="false"
    title="预警信息"
    :width="1248"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">

    <a-spin :spinning="confirmLoading">
      <a-descriptions title="" bordered>
        <a-descriptions-item label="客户名称">
          {{model.patientName}}
        </a-descriptions-item>
        <a-descriptions-item label="事件类型">
          {{model.monitorType=='1'?'心血管测评':model.monitorType=='2'?'血压测量':model.monitorType=='3'?'血糖测量':'尿酸测量'}}
        </a-descriptions-item>
        <a-descriptions-item label="数据来源">
          {{model.monitorSource}}
        </a-descriptions-item>
        <a-descriptions-item label="告警内空" >
          {{ getItemList(model.itemList)}}
        </a-descriptions-item>
        <a-descriptions-item label="告警时间" >
          {{model.createTime}}
        </a-descriptions-item>

        <a-descriptions-item label="处理状态">
          {{model.status=='0'?'待处理':model.status=='1'?'处理中':model.status=='2'?'处理完成':'不需处理'}}
        </a-descriptions-item>
      </a-descriptions>

      <a-table
        style="margin-top: 30px"
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading">
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
      </a-table>

    </a-spin>
  </a-modal>
</template>

<script>
import { httpAction, putAction, getAction, postAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
  name: 'ordStoreTableAreaModal',
  mixins: [JeecgListMixin],
  data() {
    return {
      title: '操作',
      visible: false,
      model: {},
      layout: {
        labelCol: { span: 4 },
        wrapperCol: { span: 14 }
      },
      disableMixinCreated:true,
      confirmLoading: false,
      loading:false,
      dataSource:[],
      // 表头
      columns: [
        {
          title: '处理人员',
          align: 'center',
          dataIndex: 'eyName',
          width: 150,
        },
        {
          title: '处理状态',
          align: 'center',
          dataIndex: 'status',
          width: 100,
          customRender: function(t, r, index) {
            //监控状态 0待处理 1处理中  2处理完成  3不需处理
            if (t == '0') {
              return '待处理 '
            } else if (t == '1') {
              return '处理中'
            } else if (t == '2') {
              return '处理完成'
            }
            return '不需处理'
          }
        },
        {
          title: '处理时间',
          align: 'center',
          dataIndex: 'handleTime',
          width: 180
        },
        {
          title: '处理结果',
          align: 'center',
          dataIndex: 'resultContent',
        },

      ],
      url: {
        get: '/patient/monitor/record',
        listReult:'/patient/monitor/record/result',
      }
    }
  },
  created() {
    this.modelDefault = JSON.parse(JSON.stringify(this.model))

  },
  methods: {
    getItemList(itemList){
      if(itemList==undefined){
        return ;
      }
      let textStr = '';
       itemList.forEach((item, index)=>{
        textStr+=item.indexName+"："+item.value+ '\n'
      });
      return textStr;
    },
    view(record) {
      const that = this
      that.model.id = record.id
      getAction(this.url.get + '/' + record.id).then((res) => {
        if (res.success) {
          that.model = res.result
        }
      })
      getAction(this.url.listReult + '/' + record.monitorCode).then((res) => {
        if (res.success) {
          that.dataSource = res.result
        }
      })
      that.visible = true
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      this.close()
    },
    handleCancel() {
      this.close()
    }

  }
}
</script>

<style scoped>

</style>
